package com.facebook.app.client.uiElements;

import com.facebook.app.shared.clustering.Clusterable;
import com.facebook.app.shared.facebookData.FacebookFriend;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;

public class ClusterableCell extends AbstractCell<Clusterable> {
	
	@Override
	public void render(Context context, Clusterable value, SafeHtmlBuilder sb) {
		if (value != null && value instanceof FacebookFriend) {
			
			FacebookFriend friend = (FacebookFriend) value;
			
			StringBuilder builder = new StringBuilder("<img src=\"");
			builder.append("http://graph.facebook.com/");
			builder.append(friend.getId());
			builder.append("/picture?type=square");
			builder.append("\"/>");
			
			sb.appendHtmlConstant(builder.toString()).appendEscaped(" ");
			sb.appendEscaped(friend.getName());
		}
	}

}